package com.mademoisellegeek.carrentalsimulation.comparator;

import com.mademoisellegeek.carrentalsimulation.Travel;
import com.mademoisellegeek.carrentalsimulation.Travel;
import java.util.Comparator;

/*
 * Comparator corresponding to the SHORTEST_FIRST sort method
 */
public class ShortestTravelComparator implements Comparator {

    @Override
    public int compare(Object travel1, Object travel2) {

        int length1 = ((Travel) travel1).length();
        int length2 = ((Travel) travel2).length();

        if (length1 > length2) {
            return -1;
        } else if (length1 < length2) {
            return 1;
        } else {
            return 0;
        }
    }
}